//
//  LoginViewController.m
//  HallView
//
//  Created by Lv Changye on 11-7-19.
//  Copyright 2011年 139me. All rights reserved.
//

#import "LoginViewController.h"


@implementation LoginViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [userid release];
    [password release];
    if (nick!=nil) {
        [nick release];
        nick=nil;
        [pas release];
        pas=nil;
        [email release];
        email=nil;
    }
   
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{

    nick=nil;
    email=nil;
    pas=nil;
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [userid release];
    userid = nil;
    [password release];
    password = nil;
    if (nick!=nil) {
        [nick release];
        nick=nil;
        [pas release];
        pas=nil;
        [email release];
        email=nil;
    }
    
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
	return YES;
}

- (IBAction)login:(id)sender {
    
    
    
    
}

- (IBAction)resign:(id)sender {
    [userid resignFirstResponder];
    [password resignFirstResponder];
    for (UIControl *con in [self.view subviews]) {
        [con removeFromSuperview];
    }

    UIImageView *resignBackImage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
    resignBackImage.image=[UIImage imageNamed:@"注册.png"];
    [self. view addSubview:resignBackImage];
    [resignBackImage release];
    
    nick=[[UITextField alloc]initWithFrame:CGRectMake(175, 21, 253, 47)];
    nick.delegate=self;
    [nick setKeyboardType:UIKeyboardTypeDefault];
    [nick setFont:[UIFont systemFontOfSize:18]];
    [nick setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
    [nick setReturnKeyType:UIReturnKeyNext];
    [nick.layer setCornerRadius:4];
    [self.view addSubview:nick];
    
    email=[[UITextField alloc]initWithFrame:CGRectMake(175, 86, 253, 47)];
    [email setKeyboardType:UIKeyboardTypeDefault];
    email.delegate=self;
    [email setFont:[UIFont systemFontOfSize:18]];
    [email setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
    [email setReturnKeyType:UIReturnKeyNext];
    [email.layer setCornerRadius:4];
    [self.view addSubview:email];
     
    pas=[[UITextField alloc]initWithFrame:CGRectMake(175, 151, 253, 47)];
    [pas setKeyboardType:UIKeyboardTypeDefault];
    pas.delegate=self;
    [pas setFont:[UIFont systemFontOfSize:18]];
    [pas setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
    [pas setReturnKeyType:UIReturnKeyNext];
    [pas.layer setCornerRadius:4];
    [self.view addSubview:pas];
    
    UIButton *res=[UIButton buttonWithType:UIButtonTypeCustom];
    res.frame=CGRectMake(225, 213, 168, 46);
    [res setBackgroundImage:[UIImage imageNamed:@"注册2.png"] forState:UIControlStateNormal];
    [res addTarget:self action:@selector(sureResign) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:res];
    
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
    if (textField==userid) {
        NSLog(@"userid:%@",textField.text);
    }
    else if(textField==password){
        NSLog(@"password:%@",textField.text);
    }
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    NSLog(@"RETURN!!");
    if ([password isFirstResponder]) {
        [password resignFirstResponder];
    }
    if ([userid isFirstResponder]) {
        [password becomeFirstResponder];
    }
    
    if ([pas isFirstResponder]) {
        [pas resignFirstResponder];
    }
    if ([email isFirstResponder]) {
        [pas becomeFirstResponder];
    }
    if([nick isFirstResponder]){
        [email becomeFirstResponder];
    }
    
    
    return YES;
}
-(void)sureResign{
    
}
@end
